package com.ruoyi.web.controller.system;

import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.system.domain.GwHomeSummarize;
import com.ruoyi.system.service.ISysDeptService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.service.IGwHomeSummarizeService;
import java.util.List;

/**
 * 首页汇总Controller
 * 
 * @author ruoyi
 * @date 2024-10-10
 */
@RestController
@RequestMapping("/system/summarize")
@Api(tags = "首页数据汇总")
public class GwHomeSummarizeController extends BaseController
{
    @Autowired
    private IGwHomeSummarizeService gwHomeSummarizeService;
    @Autowired
    private ISysDeptService deptService;
    /**
     * 查询首页汇总列表
     */

    @PreAuthorize("@ss.hasPermi('system:summarize:findAll')")
    @GetMapping(value = "/findMonth")
    @ApiOperation(value = "获取首页汇总当月数据", notes = "获取首页汇总当月数据")
    public AjaxResult selectGwHomeSummarizefindMonth(@RequestParam(required = false) String nodeIdentifier
            , String month  )
    {
        GwHomeSummarize data = gwHomeSummarizeService.selectGwHomeSummarizefindMonth(nodeIdentifier, month);
       //如果没有数据则都返回0
        if (data==null){
            data=new GwHomeSummarize(0L,"",0L,0L,0L,0L,0L,0L,0L);
        }
        return success(data);
    }


//    @PreAuthorize("@ss.hasPermi('system:summarize:findAll')")
//    @GetMapping(value = "/findAll")
//    @ApiOperation(value = "获取首页汇总", notes = "获取首页汇总")
//    public AjaxResult selectGwHomeSummarizeAll()
//    {
//        String node=null;findAll1ByNodeIdentifier
//        return success(gwHomeSummarizeService.selectGwHomeSummarizeAll(node));
//    }

    @PreAuthorize("@ss.hasPermi('system:summarize:findAll')")
    @GetMapping(value = "/findAll")
    @ApiOperation(value = "获取首页累计汇总", notes = "获取首页累计汇总")
    public AjaxResult findAll1ByNodeIdentifier(@RequestParam(required = false) String nodeIdentifier)
    {

        return success(gwHomeSummarizeService.selectGwHomeSummarizeAll(nodeIdentifier));
    }
    @PreAuthorize("@ss.hasPermi('system:summarize:findAll')")
    @GetMapping(value = "/findAll1ByNodeIdentifierList")
    @ApiOperation(value = "获取首页时间线汇总", notes = "获取首页时间线汇总")
    public AjaxResult findAll1ByNodeIdentifierList(@RequestParam(required = false) String nodeIdentifier
            , @RequestParam(required = false) String startDate,@RequestParam(required = false) String endDate)
    {

        return success(gwHomeSummarizeService.findAll1ByNodeIdentifierList(nodeIdentifier,startDate,endDate));
    }

    @PreAuthorize("@ss.hasPermi('system:summarize:findAll')")
    @GetMapping(value = "/findAllNodeNames")
    @ApiOperation(value = "获取所有下级节点", notes = "获取所有下级节点")
    public AjaxResult findAllNodeNames()
    {
        List<SysDept> allNodeNames = deptService.findAllNodeNames();
        AjaxResult ajax = AjaxResult.success(allNodeNames);


        return ajax;
    }







}
